#include"include/server.h"


int InitTcpServer(char *ip,char *port){
   // 建立TCP连接
   int sockfd=socket(AF_INET,SOCK_STREAM,0);
   ERROR_CHECK(sockfd,-1,"fail in socket");
   struct sockaddr_in addr;
   addr.sin_family=AF_INET;
   addr.sin_port=htons(atoi(port));
   addr.sin_addr.s_addr=inet_addr(ip);

   int ret=bind(sockfd,(struct sockaddr*)&addr,sizeof(addr));
   ERROR_CHECK(ret,-1,"fail in bind");
   listen(sockfd,50);
   return sockfd;
   
}